#include <STC15F2K60S2.H>
#include <intrins.H>
sbit RX = P1^1;
sbit TX = P1^0;
void Delay13us()		//@12.000MHz
{
	unsigned char i;

	_nop_();
	_nop_();
	i = 36;
	while (--i);
}



void csb_int()
{
	uchar i;
	for(i=0;i<8;i++)
	{
	TX = 1;
	Delay13us();
	TX = 0;
	Delay13us();
	}
}



uchar csb_read()
{
	uint temp;
	CMOD = 0X00;
	CL = CH = 0;
	EA = 0;
	csb_int();
	EA = 1;
	CR = 1;
	while(RX == 1 && CF == 0);
	CR = 0;
	if(CF == 0)
	{
		temp = (CH<<8) | CL;
		return temp*0.017;
	}else{
				CF = 0;
				return 0;
		 }
}